package com.cryptooj.project.judge;

import com.cryptooj.project.judge.codesandbox.model.JudgeInfo;
import com.cryptooj.project.judge.strategy.*;
import com.cryptooj.project.model.entity.QuestionSubmit;
import org.springframework.stereotype.Service;

/**
 *  判题管理者
 *  （简化判题服务的调用）
 * */
@Service
public class JudgeManager {

    /**
     *  执行判题
     * */
    public JudgeInfo doJudge(JudgeContext judgeContext){
        QuestionSubmit questionSubmit = judgeContext.getQuestionSubmit();
        String language = questionSubmit.getLanguage();
        JudgeStrategy judgeStrategy = new DefaultJudgeStrategy();
        if("java".equals(language)){
            judgeStrategy = new JavaLanguageJudgeStrategy();
        }
        return judgeStrategy.doJudge(judgeContext);
    }
}
